package com.cook.service.impl;

import com.cook.dto.admin.AdminLoginDTO;
import com.cook.dto.admin.AdminRegisterDTO;
import com.cook.dto.user.UserLoginDTO;
import com.cook.dto.user.UserRegisterDTO;
import com.cook.entity.Admin;
import com.cook.entity.User;
import com.cook.mapper.LoginMapper;
import com.cook.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    private LoginMapper loginMapper;

    public User getUser(UserLoginDTO dto){
        return loginMapper.getUserByNP(dto.getAccount(),dto.getPassword());
    }

    public Long addUser(UserRegisterDTO dto){
        return loginMapper.addUser(dto.getAccount(),dto.getPassword());
    }

    public Admin getAdmin(AdminLoginDTO dto){
        return loginMapper.getAdminByNP(dto.getAccount(),dto.getPassword());
    }

    public Long addAdmin(AdminRegisterDTO dto){
        return loginMapper.addAdmin(dto.getAccount(),dto.getPassword());
    }
}
